<?php
include 'XMLSerializer.php';
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * 
 */
function GenericResponseXML($statusCode, $statusMessage)
{
    $response = new Response(new GenericResponse(new Status($statusCode,$statusMessage)));    
    return XMLSerializer::generateValidXmlFromObj($response);
    //return json_encode($response);
}

function LoginResponseXML($statusCode, $statusMessage, $userid, $sessionid)
{
    $response = new Response(new LoginResponse(new Status($statusCode,$statusMessage), new Login($userid,$sessionid))); 
    return XMLSerializer::generateValidXmlFromObj($response);
}

function ArrayProjectResponseXML($statusCode,$statusMessage,$ProjectArray)
{
  $response = new Response(new ArrayProjectResponse(new Status($statusCode, $statusMessage), $ProjectArray));   
  return XMLSerializer::generateValidXmlFromObj($response,"project");
}

function ProjectResponseXML($statusCode,$statusMessage,$id,$name,$desc,$start,$end,$daysleft, $done,$budget,$status)
{
  $response = new Response(new ProjectResponse(new Status($statusCode, $statusMessage), new Project($id, $name,$desc,$start,$end,$daysleft,$done,$budget,$status)));   
  return XMLSerializer::generateValidXmlFromObj($response);
}

function ArrayMilestonesResponseXML($statusCode, $statusMessage, $ArrayOfMilestones)
{
  $response = new Response(new ArrayMilestoneResponse(new Status($statusCode, $statusMessage), $ArrayOfMilestones));
  return XMLSerializer::generateValidXmlFromObj($response,"milestone");
}

function MilestonesResponseXML($statusCode, $statusMessage, $id,$pid,$name,$desc,$start,$end,$status)
{
  $response = new Response(new MilestoneResponse(new Status($statusCode, $statusMessage), new Milestone($id,$pid,$name,$desc,$start,$end,$status)));
  return XMLSerializer::generateValidXmlFromObj($response);
} 
function ArrayTasklistResponseXML($statusCode, $statusMessage, $ArrayOfTasklists)
{
  $response = new Response(new ArrayTasklistResponse(new Status($statusCode, $statusMessage), $ArrayOfTasklists));
  return XMLSerializer::generateValidXmlFromObj($response,"tasklist");
}

function TasklistResponseXML($statusCode, $statusMessage, $tlid, $pid, $mid, $name, $desc, $start, $status, $access)
{
  $response = new Response(new TasklistResponse(new Status($statusCode, $statusMessage),new Tasklist( $tlid, $pid, $mid, $name, $desc, $start, $status, $access)));
  return XMLSerializer::generateValidXmlFromObj($response);
}

function ArrayTasksResponseXML($statusCode, $statusMessage, $ArrayOfTasks)
{
  $response = new Response(new ArrayTaskResponse(new Status($statusCode, $statusMessage), $ArrayOfTasks));
  return XMLSerializer::generateValidXmlFromObj($response,"task");
}

function TasksResponseXML($statusCode, $statusMessage, $id,$pid,$tlid,$name,$desc,$start,$end,$status)
{
    
  $response = new Response(new TaskResponse(new Status($statusCode, $statusMessage), new Task($id,$pid,$tlid,$name,$desc,$start,$end,$status)));
  return XMLSerializer::generateValidXmlFromObj($response);
}

function RoleResponseXML($statusCode, $statusMessage, $name, $project, $tasks, $milestones, $messages, $files, $timetracker, $chat, $admin)
{
    $response = new Response(new RoleResponse(new Status($statusCode, $statusMessage),
                                              $name,
                                              new Role($project['add'],$project['edit'],$project['del'],$project['close'],$project['read']),
                                              new Role($tasks['add'],$tasks['edit'],$tasks['del'],$tasks['close'],$tasks['read']),
                                              new Role($milestones['add'],$milestones['edit'],$milestones['del'],$milestones['close'],$milestones['read']),
                                              new Role($messages['add'],$messages['edit'],$messages['del'],$messages['close'],$messages['read']),
                                              new Role($files['add'],$files['edit'],$files['del'],$files['close'],$files['read']),
                                              new Role($timetracker['add'],$timetracker['edit'],$timetracker['del'],$timetracker['close'],$timetracker['read']),
                                              new Role($chat['add'],$chat['edit'],$chat['del'],$chat['close'],$chat['read']),
                                              new Role($admin['add'],$admin['edit'],$admin['del'],$admin['close'],$admin['read'])
                 ));
    return XMLSerializer::generateValidXmlFromObj($response);
}

?>
